package com.zr.d_c.controller;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import com.zr.d_c.service.AdminService;
import com.zr.d_c.service.SellerService;
import com.zr.d_c.serviceimpl.AdminServiceImpl;
import com.zr.d_c.serviceimpl.SellerServiceImpl;
/**
 * 管理员撤销商家删除账户的操作
 * @author Administrator
 *
 */
public class CancelSellerDeleteController extends HttpServlet{
	AdminService adminservice = new AdminServiceImpl(); 
	SellerService sellerservice = new SellerServiceImpl();
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
	// TODO Auto-generated method stub
	doPost(req, resp);
}
@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		// TODO Auto-generated method stub
		int i = Integer.parseInt(req.getParameter("count"));
//		HttpSession session = req.getSession();
		PrintWriter pw = resp.getWriter();
		if(i>0){
			for(int j =0;j<i;j++){
				int sid = Integer.parseInt(req.getParameter("sellers["+j+"][sid]"));
				adminservice.cancelSellerDeleteInSeller(sid);
				int uid = Integer.parseInt(req.getParameter("sellers["+j+"][uid]"));
				adminservice.cancelSellerDeleteInUser(uid);
			}
			pw.write("1");
		}else{
			pw.write("0");
		}
	}
}
